import pymysql


class MySql():
    def __init__(self, user, password, host, databases):
        self.con = pymysql.connect(host=host, user=user, password=password, database=databases)
        self.cur = self.con.cursor()

    def search(self, sql):
        self.cur.execute(sql)

        return self.cur.fetchall()

    def insert(self, name):
        self.cur.execute('insert into title (name)values("%s")' % name)
        self.con.commit()

    def close(self):
        self.cur.close()
        self.con.close()
